﻿#pragma once

#include <log4lite/t_string.h>
#include <log4lite/log_catagory.h>

namespace log4lite {
	
	class LogItem;

	class Layout
	{
	public:
		Layout() {}
		virtual ~Layout() {}

		virtual void formatAndAppend(tostream& output, const LogItem& item) = 0;
	
	protected:
		LogCatagoryManager _lcm;

	private:
		Layout(const Layout&);
		Layout& operator=(Layout&);
	};

	/// 最基本布局
	class SimpleLayout : public Layout 
	{
	public:
		SimpleLayout() {}
		virtual void formatAndAppend(tostream& output, const LogItem& item);

	private: 
		// Disallow copying of instances of this class
		SimpleLayout(const SimpleLayout&);
		SimpleLayout& operator=(const SimpleLayout&);
	};
	
	/// Song定义的志格式
	class SongLayout : public Layout 
	{
	public:
		SongLayout() {}
		virtual void formatAndAppend(tostream& output, const LogItem& item);
	private: 
		SongLayout(const SongLayout&);
		SongLayout& operator=(const SongLayout&);
	private:
		tchar _fname[100];
		tchar _ext[100];
	};

	/// Linux系统日志格式
	class SyslogLayout : public Layout 
	{
	public:
		SyslogLayout();
		virtual void formatAndAppend(tostream& output, const LogItem& item);
	
	private:
		char _hostName[256]; ///< 主机名

	private: 
		SyslogLayout(const SimpleLayout&);
		SyslogLayout& operator=(const SimpleLayout&);
	};

} // namespace log

